Recently the company requested to back up the database, so we looked up the comparative information. Don't say much nonsense, into the subject.Objective: To regularly back up the Postgres database under Ubuntu, and to pack and upload to the
PG processing time is very flexible, +-*/both have supportIt's useful to have a extract function in the meantime, let's take a look at a few examples: [code]postgres=# Select Extract (Epoch from ' 1970-01-01 ':: timestamp);Date_part-----------0(1
Get system Time function
Select Now (); --2013-11-28 16:20:25.259715+08
Select Current_timestamp; --2013-11-28 16:20:38.815466+08
Select current_date; --2013-11-28
Select Current_time; --16:21:08.981171+08
Calculation
Commonly used time and date scripts in PostgreSQL tutorial, postgresql tutorial
Obtain System Time Functions
select now(); --2013-11-28 16:20:25.259715+08select current_timestamp; --2013-11-28 16:20:38.815466+08select current_date; --2013
1. Function Description:Date_trunc: Intercept a given time (timestamp,date) to get the initial time of the specified precision (time, day, month, year)2. General TimeDate_trunc (' Hour ', TIMESTAMP ' 2018-08-16 20:38:40 ')Result:2018-08-16
It's not surprising when those of us who use rails see things like 5.weeks.from_nowor3.days.ago + 2.hours. Also, PostgreSQL can do this by simply calling PostgreSQL built-in functions to achieve the same functionality.Current time/date/time stamp
Those of us who use Rails will not be surprised when they see 5. weeks. from_nowor3.days.ago + 2. hours. Similarly, PostgreSQL can also achieve the same functionality by simply calling the built-in functions of PostgreSQL.
PostgreSQL deletes
PostgreSQL has a very useful built-in function, generate_series, which can be used to generate a series of filled data according to different rules.I. Syntax
generate_series(start,stop) --int or bigintgenerate_series(start,stop,step)
Those of us who use Rails will not be surprised when they see 5. weeks. from_nowor3.days.ago + 2. hours. You can also use PostgreSQL.
Those of us who use Rails will not be surprised when they see 5. weeks. from_nowor3.days.ago + 2. hours. You can
I. Type conversionPostgres type conversion: Usually: used for type conversion, timestamp to date is used moreSelect now (): DateSelect now (): varcharExample 1: varchar of a date is calculated as date.Select '2017-11-15 16:15:56. 2012 + 08':
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.